<?php


class m_user extends M {



	function __init__ () {
	
		$this->db->settable("www_user");
	
	}
	
	function userindex($openid) {
	
		$vo = $this->db->where(array("openid"=>$openid))->find();
		
		if($vo) {
		
			$this->php->session->userid=$vo["id"];
		
		}else {
			
			$data["openid"] = $openid;
			$data["ctime"] = time();
			$data["etime"] = time();
			$id = $this->db->insert($data);
			
			
			if(empty($id)){
			
				echo "不好意思，系统出错";
				/*
					这里得好好处理一下。出错了得记录下来，并且得返回友好界面
				*/
			
			}else{
			
			
				$data2["userid"] = $id;
				$data2["ctime"] = time();
				$data2["etime"] = time();
				
				$qiyeid = $this->db->settable("www_qiye")->insert($data2);
				
				/*
					这里得好好处理一下。出错了得记录下来，并且得返回友好界面
				*/
				if($qiyeid){
					$this->session->userid=$id;
				}else {
				
				}
				
			}
			
			
			
			
		}
		
	
	}












}